import request from '@/utils/request'

export function register(data) {
  return request({
    url: '/account/register',
    method: 'post',
    data
  })
}

export function sendActiveEmail(email) {
  return request({
    url: '/account/sendEmail?email=' + email,
    method: 'get'
  })
}
export function fetchAccountList(query) {
  return request({
    url: '/account/list',
    method: 'get',
    params: query
  })
}

export function save(data) {
  return request({
    url: '/account/update',
    method: 'patch',
    data
  })
}

export function create(data) {
  return request({
    url: '/account/createAccount',
    method: 'post',
    data
  })
}

export function deleteAccount(username) {
  return request({
    url: '/account/' + username,
    method: 'delete'
  })
}

export function findByUsername(username) {
  return request({
    url: '/account/' + username,
    method: 'get'
  })
}

export function getRoleList(query) {
  return request({
    url: '/role/roleList',
    method: 'get',
    params: query
  })
}

export function resetAccount(username) {
  return request({
    url: '/account/' + username,
    method: 'patch'
  })
}
